using UnityEngine;

namespace ExceptionModule
{
    public class ExceptionManager : IExceptionManager
    {
        private readonly ICustomLogHandler _logHandler;

        public ExceptionManager(ICustomLogHandler logHandler)
        {
            _logHandler = logHandler;
        }

        public void Initialize()
        {
            Application.quitting += Quit;
            Application.logMessageReceived += _logHandler.HandleLog;
        }

        public void Quit()
        {
            Application.logMessageReceived -= _logHandler.HandleLog;
            Application.quitting -= Quit;
        }
    }
}